< previous page page_414 next page >

Page 414
End Function

' Get a VB string from an address
Public Function GetVBStringFromAddress(ByVal addr&) As String
    Dim uselen&
    Dim res$
    If addr = 0 Then Exit Function
    uselen = lstrlen(addr)
    res$ = String$(uselen + 1, 0)
    Call lstrcpy(res, addr)
    GetVBStringFromAddress = Left$(res$, uselen)
End Function
The ServiceStatus class also has properties to read the name, display name, and current running state of the service.
The ServiceObject class is relatively straightforward. It stores the service handle internally, along with the name and display name of the service. It has methods to stop, start, and obtain status for a service. These methods basically call the corresponding API function.
' Service Object Class
' Copyright © 1998 by Desaware Inc. All Rights Reserved

' This object represents an open service

Option Explicit

Private intServiceHandle As Long
Private intServiceName As String
Private intDisplayName As String

' For convenience, this object is initialized by the ServiceManager
' with both the name and display name
Friend Sub Initialize(ByVal hnd As Long, Name As String, _
DisplayName As String)
    intServiceHandle = hnd
    intServiceName = Name
    intDisplayName = DisplayName
End Sub

' Get the short name
Property Get ServiceName() As String
    ServiceName = intServiceName

 
< previous page page_414 next page >